﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PedidoWeb.Util
{
    public class Util
    {

        private static Util singleton = null;

        private Util() { }

        public static Util getInstance() 
        {
            if (singleton == null) {
                singleton = new Util();
            }

            return singleton;
        }

        public bool isDecimal(String numero)
        {
            decimal valorConvertido = 0;

            return Decimal.TryParse(numero, out valorConvertido);
        }

        public bool isInteiro(String numero)
        {
            int valorConvertido = 0;

            return int.TryParse(numero, out valorConvertido);
        }

        public bool isDate(String data)
        {
            IFormatProvider culture = new System.Globalization.CultureInfo("pt-BR", true);

            DateTime dataConvertida;

            return DateTime.TryParse(data, culture, System.Globalization.DateTimeStyles.AssumeLocal, out dataConvertida);
        }

        public DateTime convertToDate(String data)
        {
            IFormatProvider culture = new System.Globalization.CultureInfo("pt-BR", true);

            return DateTime.Parse(data, culture, System.Globalization.DateTimeStyles.AssumeLocal);
        }

    }
}